<template>
  <a-modal
        :title="title"
        :width="560"
        :visible="visible"
        :body-style="{paddingBottom: '100px',height:'520px',overflowY:'auto'}"
		:dialogStyle="{top:'50px'}"
		:maskClosable="false"
       @ok="onOk"
       @cancel="onCancel"
  >
	<a-form-model ref="liForm" :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="rules">
		<a-form-model-item label="id" v-show="false">
		  <a-input v-model="form.id" />
		</a-form-model-item>
				<a-form-model-item label="政策标题" >
				  <a-input v-model="form.title" placeholder="政策标题"/>
				</a-form-model-item>
				<a-form-model-item label="政策分类" prop="type" >
				  <a-select v-model="form.type" placeholder="请输入政策分类">
				    <a-select-option  v-for="(obj, index) in typedata" :key="index" :value="obj.name">{{obj.name}}</a-select-option>
				  </a-select>
				</a-form-model-item>
				<a-form-model-item label="政策内容" prop="contents">
					<a-textarea v-model="form.contents" placeholder="请输入政策内容" :auto-size="{ minRows: 6, maxRows: 8 }"/>
				</a-form-model-item>
		</a-form-model>
  </a-modal>
</template>

<script>
import {getUrl} from '@/api/manage'
export default {
  components:{
   
  },
  name:"PolicyInfoForm",
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    loading: {
      type: Boolean,
      default: () => false
    },
    model: {
      type: Object,
      default: () => null
    },
    title: {
      type: String,
      default : ''
    }
  },
  data () {
    return {
      labelCol: { span: 4 },
      wrapperCol: { span:20 },
	  selecetPosition : triggerNode => {return triggerNode.parentNode || document.body;},
      form: {
          id:'',
          title: undefined,
          type: undefined,
          contents: ''
      },
	  typedata:[],
      rules: {
        title: [
          {required: true, message: '政策标题不能为空', trigger: 'blur' },
         
        ],
        type: [
          {required: true, message: '政策分类不能为空', trigger: 'change' },
          
        ],
        contents: [
          {required: true, message: '政策内容不能为空', trigger: 'blur' },
          
        ]
      },
    }
  },
  created () {
    // 当 model 发生改变时，为表单设置值
    this.$watch('model', () => {
      Object.assign(this.form, this.model)
    })
  },
  methods: {
    onCancel() {
       this.$emit("cancel",this)
    },
    onOk() {
       this.$emit("ok",this)
    }
  }
}
</script>
<style>
</style>
